INNER CODE UNIT · Python

send_message

opsdroid/opsdroid · opsdroid/connector/facebook/__init__.py:111

    async def send_message(self, message):
        """Respond with a message."""
        _LOGGER.debug(_("Responding to Facebook."))
        url = _FACEBOOK_SEND_URL.format(self.config.get("page-access-token"))
        headers = {"content-type": "application/json"}
        payload = {
            "recipient": {"id": message.target},
            "message": {"text": message.text},
        }
        async with aiohttp.ClientSession(trust_env=True) as session:
            resp = await session.post(url, data=json.dumps(payload), headers=headers)
            if resp.status < 300:
                _LOGGER.info(_("Responded with: %s."), message.text)
            else:
                _LOGGER.debug(resp.status)
                _LOGGER.debug(await resp.text())
                _LOGGER.error(_("Unable to respond to Facebook."))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…