# Teams/Slack chatbots
URL: https://docs.datarobot.com/en/docs/api/dev-learning/accelerators/llm-and-genai-apps/chatbot-teams-slack.html

> An accelerator for collaborative app plug-ins, such as bots for Teams and Slack.

# Teams/Slack chatbots

Slack and Microsoft teams support the creation of applications or bots that can interact with a DataRobot deployment. Using Slack or Teams as a front-end for a LLM-based chat application enables broad availability in an organization, providing the ability to upload documents easily as well as leverage internal knowledge stored in team channels or conversations.

**Slack setup:**
Obtain permissions from your IT organization to create a Slack App in your Slack organization. Then, [create the app](https://api.slack.com/apps) with the Slack API.

**Teams setup:**
Obtain permissions from your IT organization to upload a customized app. Then, register for an application and a ot in the [Microsoft Developer Portal](https://login.microsoftonline.com).


Within the message send action in both Slack and Teams, export the user question as a prompt into your DataRobot LLM deployment, and provide the response from the REST API call to the user message in your bot. DataRobot enables you to track token usage, prompts, responses, toxicity, and other [custom metrics](https://docs.datarobot.com/en/docs/api/reference/sdk/custom-metrics.html) to monitor and govern your application internally.

The following code can be adapted to the Slack or Teams messaging structure to pass a message as a query to the DataRobot LLM deployment and get a response.

```
    import datarobotx as drx

    # configure drx LLM Deployment
    RAG = drx.Deployment.from_url(
        url=f'https://app.datarobot.com/deployments/{RAG_did}/overview'
    )

    def make_datarobot_deployment_unstructured_predictions(
        data,
        **kwargs,
    ):
        query = json.loads(data)
        response = RAG.predict_unstructured(query)
        return json.dumps(response)

    def make_prediction(prompt, history=None) -> dict:

        data = {
            "prompt": prompt,
        }
        if history:
            data["chat_history"] = [
                [entry.get("user", ""), entry.get("chatbot", "")] for entry in history
            ]
        response = make_datarobot_deployment_unstructured_predictions(
            json.dumps(data)
        )
        response = json.loads(response)

        return response
```

---
