Integrações

Webhooks de Entrada para o Pumble

5 min de leitura
jovana

Com os webhooks de entrada, você pode postar mensagens facilmente de outros aplicativos no Pumble. Ao criar um webhook de entrada, você recebe um URL exclusivo pelo qual pode enviar uma carga JSON com o texto da mensagem.

Criando um webhook de entrada #

Para criar um novo webhook de entrada:

  1. Clique no nome do seu espaço de trabalho no canto superior esquerdo
  2. Acesse as Configurações do espaço de trabalho
  3. Selecione Configurações gerais no menu suspenso
  4. Clique na seção Webhooks de entrada na barra lateral
  5. Clique no botão Novo Webhook no canto superior direito
  6. Escolha o canal onde seu webhook postará mensagens
  7. Clique no botão Adicionar Webhooks de entrada para concluir o processo

When you create your webhook, the editor opens up automatically. There, you’ll be able to customize its name, change the channel, add a descriptive label, customize the icon, and most importantly, copy or regenerate your unique URL.

Informações

The rate limit on incoming webhooks on Pumble is 1 second per webhook.

Informações

O número máximo de caracteres em um webhook é 10000.

Usando webhook de entrada para enviar uma mensagem #

To send a message using the incoming webhooks you just created, simply make an HTTP POST request to the unique URL you copied from the webhook editor.

A carga útil da solicitação deve conter a propriedade texto e esse texto será enviado para um canal especificado. Os tipos de conteúdo atualmente suportados são:

  • application/json
  • application/x-www-form-urlencoded

Here is a sample curl request for posting to a channel using an incoming webhook using the application/x-www-form-urlencoded content type:

curl -X POST \ --location "https://api.pumble.com/workspaces/WORKSPACE-ID/incomingWebhooks/postMessage/WEBHOOK-CODE" \ --data-urlencode "payload={ \"text\": \"This is posted to general and comes from a bot named MyNewWebhook.\" }"

Aqui está um exemplo de solicitação JSON curl para postar em um canal usando um webhook de entrada:

curl -X POST \ --location
  "https://api.pumble.com/workspaces/WORKSPACE-ID/incomingWebhooks/postMessage/WEBHOOK-CODE" \
  -H "Content-Type: application/json" \
  -d '{"text":"This is posted to general and comes from a bot named MyNewWebhook."}'
Informações

Você pode usar formatação rich text para mensagens webhook. Aqui estão alguns exemplos de payload:

Menção do usuário:

{
   "text": "User mention: <<@{{userId}}>>, channel mention: <<#{{channelId}}>>, user group mention: <<&{{userGroupId}}>> and @here @channel"
}

Anexo:

{
   "attachments": [
       {
           "pretext": "Pretext of Pumble webhooks article",
           "title": "Pumble webhooks",
           "title_link": "https://pumble.com/help/integrations/add-pumble-apps/incoming-webhooks-for-pumble",
           "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
           "author_name": "Pumble",
           "author_link": "https://pumble.com",
           "footer": "Lorem ipsum v1.0.0",
           "footer_icon": "https://files.pumble.com/avatars/default/pumble-logo",
           "color": "green", // or hex RGB
           "ts": 1759479334
       }
   ]
}

Este exemplo de anexo enviará uma mensagem parecida com esta:

Hiperlinks:

{
    "text": "[Markdown Hyperlink](https:\/\/pumble.com) | <a href=\"https:\/\/pumble.com\">Html hyperlink<\/a> | <https:>"
}

Emojis:

{
   "text": "Emojis :raised_hands: :heart:"
}

Bloco de código:

{
   "text": "`Inline code` and ```Code block\n hello \nEnd of code block```"
}

Aqui está um exemplo de mensagem que incorpora diferentes tipos de formatação de rich text:

{
    "text": "Hello team! :wave: :tada:\n\n**Quick Update**:\n- Feature deployed successfully! :rocket:\n- Bugs resolved: `5`\n\n*Styling Reference:*\n- Markdown **bold**, *italic*\n- HTML <b>bold<\/b>, <i>italic<\/i>, <code>inline code<\/code>\n\n\ud83d\udd17 Useful Links:\n- [Pumble Website](https:\/\/pumble.com)\n- <a href=\"https:\/\/pumble.com\">Pumble via HTML<\/a>\n- <https:> \n\n:busts_in_silhouette: Mentions:\n- Channel: <<#{{68e3a383ce5f2c8d95ff46a6}}>> \nNotifications: @here @channel \n\n:computer: Code snippet:```function greet() {\n  console.log(\"Hello, Pumble!\");\n}```"
}

Esta mensagem do webhook ficaria assim:

Processar os erros #

If everything is set up correctly, you’ll receive an HTTP 200 status to indicate that your incoming webhook was successful. This might not always be the case, and this action can fail for numerous reasons.

Use the following table to troubleshoot common webhook errors.

Error codeError messageCause
400440Channel is archived.The channel where the webhook is sending messages is archived.
400700Incoming webhook is disabled.The webhook was disabled by the Workspace Admin.
400702Incoming webhook is deleted.The webhook was deleted by the Workspace Admin.
400703Invalid payload format.The request payload is not in a supported format.
403200You cannot perform this operation.You don’t have permission to post in the specified channel.
404100Not found.The unique URL was not found and most likely regenerated by a Workspace Admin.

Esse artigo foi útil?

Thank you! If you’d like a member of our support team to respond to you, please drop us a note at support@pumble.com