API commands and script examples: Difference between revisions
From Planfix
No edit summary |
No edit summary |
||
Line 133: | Line 133: | ||
''' | '''Sample call:''' | ||
<source lang="bash"> | <source lang="bash"> | ||
POST https://domain/planfix_api.php | POST https://domain/planfix_api.php | ||
Line 141: | Line 141: | ||
chatId=EFHASFN1239351 | chatId=EFHASFN1239351 | ||
token=202cb962ac59075b964b07152d234b70 | token=202cb962ac59075b964b07152d234b70 | ||
message= | message=Hello, how can I help you? | ||
userName= | userName=Peter | ||
userLastName= | userLastName=Peterson | ||
userIco=https:// | userIco=https://account_name.planfix.com/?action=getuserpic&id=77 | ||
attachments[name]= | attachments[name]=file1.doc | ||
attachments[url]=https:// | attachments[url]=https://account_name.planfix.com/file/aadkapdoa5456454 | ||
attachments[name]= | attachments[name]=file2.doc | ||
attachments[url]=https:// | attachments[url]=https://account_name.planfix.com/file/aadkapdoa5456455 | ||
</source> | </source> | ||
'''Параметры ответа:''' | '''Параметры ответа:''' |
Revision as of 01:39, 25 June 2019
Commands from third-party chats to Planfix
newMessage (POST)
Command to send a new message from a third-party chat to Planfix.
Call parameters:
Name | Description | Data type/format | Note |
---|---|---|---|
cmd | type of operation, in this case newMessage | string | |
providerId | third-party system identifier | string | cannot contain the symbol "~" |
channel | additional channel identifier on the third-party system side | string | not required, can be used as needed. |
chatId | unique chat ID | string | |
planfix_token | Planfix key (token), specified in the integration settings | string | |
message | message content | string | |
title | message header | string | not required; if it exists, it's used to create task names |
contactId | contact's unique identifier | string | |
contactName | contact's first name | string | |
contactLastName | contact's last name | string | not required |
contactIco | contact's picture | string | not required |
contactEmail | contact's email | string | not required |
contactPhone | contact's phone number | string | not required |
contactData | additional contact data | string | not required |
attachments[name] | attachment (name) | string | not required, several allowed |
attachments[url] | attachment (link) | string | not required, several allowed |
isEcho | outgoing message | boolean | not required |
Sample call:
POST https://test.planfix.ru/chat/api
cmd=newMessage
providerId=superchat
chatId=EFHASFN1239351
planfix_token=303cb962ac59075b964b07152d234b70
message=Hello, I have a question
contactId=57487124
contactName=Ivan
contactLastName=Ivanov
contactIco=https://superchat.io/avatars/183712.png
contactEmail=ivan@ivanov.com
contactPhone=79051234567
contactData=the gas boilers came as expected
attachments[name]=photo1.jpg
attachments[url]=https://superchat.io/files/5444.jpg
attachments[name]=photo2.jpg
attachments[url]=https://superchat.io/files/5445.jpg
Response options:
HTTP code | Body | Description |
---|---|---|
200 | ОК | |
400 | { error: "Invalid parameters" } | Incorrect parameters passed |
401 | { error: "Invalid token" } | Invalid key (token) passed |
Commands from Planfix to third-party chats
newMessage (POST)
Command for passing a new message from Planfix to a third-party chat.
Call parameters:
Name | Description | Data type/format | Note |
---|---|---|---|
cmd | type of operation, in this case newMessage | string | |
providerId | third-party system identifier | string | |
chatId | unique chat ID | string | |
contactPhone | contact's phone number | string | not required |
channel | additional channel identifier on the third-party system side | string | not required, can be used as needed |
token | third-party chat key (token), specified in the integration settings | string | |
message | message content | string | |
userName | first name of employee who responded | string | |
userLastName | last name of employee who responded | string | |
userIco | profile picture of employee who responded | string | |
taskEmail | task email address in Planfix | string | |
attachments[name] | attachment (name) | string | необязательный, допускается несколько |
attachments[url] | attachment (link) | string | необязательный, допускается несколько |
Sample call:
POST https://domain/planfix_api.php
cmd=newMessage
providerId=superchat
chatId=EFHASFN1239351
token=202cb962ac59075b964b07152d234b70
message=Hello, how can I help you?
userName=Peter
userLastName=Peterson
userIco=https://account_name.planfix.com/?action=getuserpic&id=77
attachments[name]=file1.doc
attachments[url]=https://account_name.planfix.com/file/aadkapdoa5456454
attachments[name]=file2.doc
attachments[url]=https://account_name.planfix.com/file/aadkapdoa5456455
Параметры ответа:
Имя | Описание | Тип/формат данных | Примечание |
---|---|---|---|
chatId | уникальный id чата | string | |
contactId | уникальный идентификатор контакта | string |
Варианты ответа:
HTTP код | Тело | Описание |
---|---|---|
200 | { chatId: "chatId", contactId: "contactId" } | ОК |
400 | { error: "Invalid parameters" } | Переданы некорректные параметры |
401 | { error: "Invalid token" } | Передан неверный ключ (token) |
Перейти