# Source: https://docs.avaamo.com/user-guide/ref/avaamo-platform-api-documentation/microsoft-teams-send-api.md

# Microsoft Teams Send API

{% hint style="success" %}
**Pre-requisite**: You must have an agent with the MS Teams channel configured. See [MS Teams channel](https://docs.avaamo.com/user-guide/how-to/build-agents/configure-agents/deploy/microsoft-teams-ms-teams), for more information.
{% endhint %}

## Outbound API to send a message from the MS Teams channel to the user

<mark style="color:green;">`POST`</mark> `https://cx.avaamo.com/teams/{{channel_uuid}}/send.json`

#### Path Parameters

| Name          | Type   | Description                                                                                                                                                                                                                                                                                                                                                 |
| ------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| channel\_uuid | String | <p>Unique channel identifier generated by the Platform when the MS Teams channel is configured. </p><p></p><p>This helps to identify the source of the request when an message is sent to the user using this API. See <a href="../../how-to/build-agents/configure-agents/deploy/microsoft-teams-ms-teams">MS Teams channel</a>, for more information.</p> |

#### Request Body

| Name                          | Type                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| email                         | String               | <p>Valid user email to whom the message is sent. </p><p></p><p>Required, if custom user authentication is not enabled in the MS Teams channel. </p><p></p><p>If custom user authentication is enabled, then you must return <code>email</code> , <code>message</code>, along with <code>uuid</code> in the  <strong>User authentication handler</strong> block<strong>.</strong> This provides flexibility to the developers to authenticate the users and then return the email to whom the message must be sent. See <a href="../../../how-to/build-agents/configure-agents/define-settings#ms-teams-channel">User authentication handler</a>, for more information.</p>                                                              |
| <\<custom\_params>>           | JSON key-value pairs | <p>Any custom parameters such as the first name, last name, and employee id can be included in the body payload as per the requirement. </p><p></p><p>These parameters are available in <code>context.params.<\<custom\_param>></code> and can be used for authenticating the users in the <strong>User authentication handler</strong> when custom user authentication is enabled in the MS Teams channel.  See <a href="../../../how-to/build-agents/configure-agents/define-settings#ms-teams-channel">User authentication handler</a>, for more information.</p>                                                                                                                                                                    |
| message -> text               | String               | <p>Valid message sent to the user vi MS Teams channel. </p><p></p><p>Either a text message or a CustomTeamsMessage is</p><p>required, if custom user authentication is not enabled in the MS Teams channel. </p><p></p><p>If custom user authentication is enabled, then you must return <code>email</code> , <code>message</code>, along with <code>uuid</code> in the  <strong>User authentication handler</strong> block<strong>.</strong> This provides flexibility to the developers to authenticate the users and then return the email to whom the message must be sent. See <a href="../../../how-to/build-agents/configure-agents/define-settings#ms-teams-channel">User authentication handler</a>, for more information.</p> |
| message -> CustomTeamsMessage | JSON                 | <p>MS Teams custom payload. </p><p></p><p>Either a text message or a CustomTeamsMessage is</p><p>required, if custom user authentication is not enabled in the MS Teams channel. </p><p></p><p>If custom user authentication is enabled, then you must return <code>email</code> , <code>message</code>, along with <code>uuid</code> in the  <strong>User authentication handler</strong> block<strong>.</strong> This provides flexibility to the developers to authenticate the users and then return the email to whom the message must be sent. See <a href="../../../how-to/build-agents/configure-agents/define-settings#ms-teams-channel">User authentication handler</a>, for more information.</p>                            |

{% tabs %}
{% tab title="200: OK Successful request. " %}

```javascript
{
    "success": true
}  

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note**:  After a successful request, a conversation is established and can be tracked using `email` from the Conversation history page. See [Conversation history](https://docs.avaamo.com/user-guide/how-to/build-agents/debug-agents/conversation-history), for more information.
{% endhint %}

### Code request snippets

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl -X POST \
http://cx.avaamo.com/teams/62b783fb-86e0-xxxx-b8f0-2144xxxxxxxxx/send.json \
-H 'content-type: application/json' \
-d '{ 
   "first_name": "John",
   "last_name": "Jacob",
   "emp_id": "1234",
   "email": "jacob.john@abc.com",
   "message": {
      "text": "Your message goes here."
   }
 }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Examples

**Request**: The following is a sample JSON request for posting a simple message to the user:

```json
{ 
   "first_name": "John",
   "last_name": "Jacob",
   "emp_id": "1234",
   "email": "jacob.john@abc.com",
   "message": {
      "text": "Your message goes here."
   }
}
```

**Request**: The following is a sample JSON request for posting a custom teams message to the user:

```json
{ 
   "first_name": "John",
   "last_name": "Jacob",
   "emp_id": "1234",
   "email": "jacob.john@abc.com",
   "message": {
      "CustomTeamsMessage": { 
          <<your-ms-teams-payload-here>>
      }
   }
 }
```