Personal Agent
Personal Agents are automated assistants that can help manage and interact with personal messages in MeWe. This app is also pure backend application that is a bot that can be added to multiple chat threads where its owner is participant. There is possibility to chat as an owner with that bot directly in personal chat thread.
Setting up
To setup this bot you need to:
- Setup application type of personal_agent with user_chats permission and post_content, webhookUrl also has to be added
- Setup public webhook endpoint on your backend application
Authentication
Headers that every api request requires:
stringyour application id
stringagent it, which is userId of the agent
numbertimestamp that should be the time of making the request (it protects against replay attacks), its a unix timestamp seconds
hexssignature which is hex representation of hmacSha256 signture of payload combined with headers signed with an apiKey: {appId}:{agentId}:{timestamp}:{json_payload_no_white_spaces}
Webhook events
Personal agent app can receive events via webhooks. All webhooks calls will be authenticated similar way as app has to authenticate api calls, however its up to developer if should be checked or not. It will have a bit different headers and the signature payload: no X-App-Id but X-Event instead which is unique event name, X-Agent-Id, X-Timestamp, X-Signature stays the same. Signature formula: {timestamp}:{agentId}:{eventType}:{json_payload_no_white_spaces}. Webhook events with example payloads:
- personal_agent_registered - triggered when a personal agent is added to a personal chat thread
{
"agentName": "MuadDib",
"ownerId": "607595295635495b3c80f6cd",
"ownerFirstName": "Pétur",
"personalChatThreadId": "60ffe9492f19cd2677b0f1a8"
}
- personal_agent_unregistered - triggered when a personal agent is removed from a chat thread
{
"ownerId": "607595295635495b3c80f6cd"
}
- personal_chat_mention - triggered when a personal agent is mentioned in a chat message
{
"threadId": "60ffe9492f19cd2677b0e1b1",
"chatMessageId": "60ffe9492f19cd2677b0e2a2",
"messageText": "Hey {{u_625568bf663e8f63481b04ab}MuadDib!} How's going?",
"userId": "607595295635495b3c80f6cd",
"userName": "Pétur Jureksson"
}
- personal_agent_joined_chat - triggered when a personal agent is added to a chat thread
{
"threadId": "60ffe9492f19cd2677b0e1b1",
"agentId": "607595295633495b3c80f6cf",
"agentName": "Thor",
"ownerId": "607595295635495b3c80f6cd",
"ownerName": "Pétur Jureksson"
}
- personal_agent_left_chat - triggered when a personal agent is removed from a chat thread
{
"threadId": "60ffe9492f19cd2677b0e1b1",
"agentId": "607595295633495b3c80f6cf"
}
- personal_user_joined_chat - triggered when a user joins a chat thread
{
"threadId": "60ffe9492f19cd2677b0e1b1",
"userId": "607595295635495b3c80f7de",
"userName": "Sigrún Guðmundsdóttir"
}
- personal_user_left_chat - triggered when a user leaves a chat thread
{
"threadId": "60ffe9492f19cd2677b0e1b1",
"userId": "607595295635495b3c80f7de",
"userName": "Sigrún Guðmundsdóttir"
}
- personal_chat_message - triggered when a chat message is sent
{
"threadId": "60ffe9492f19cd2677b0e1b1",
"chatMessageId": "60ffe9492f19cd2677b0e2a2",
"messageText": "Maybe yes, maybe not",
"userId": "607595295635495b3c80f6cd",
}
Api
Personal agent can either send chat message or read messages in thread it sits in
Helpful api
- creating personal agent See agents api section
- Modifying agent’s photo: See agents api section
- Agent deletion: See agents api section
- List of owned agents: See agents api section
- Add agent to chat thread See agents api section
- Remove agent from chat thread See agents api section