Guides Data pipelines

Post new innovations to Slack

Share fresh innovations for your industry in a team channel.

3 steps8 min

  1. Create a Slack webhook

    In Slack, add an Incoming Webhook to the channel and copy its URL.

    Shell
    export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."
  2. Find your industry id

    Look up the industry you care about once and keep its id.

    Python
    for ind in tw.industries():
        print(ind.industry_id, ind.name)
  3. Post what's new

    Use the change feed so each run only sees new or updated innovations, keep the ones in your industry, and post their ready-made display card.

    Python
    import json, os, pathlib
    import httpx
    from trendwatching import TrendWatching
    
    INDUSTRY_ID = 4
    tw = TrendWatching(api_key=os.environ["TW_API_KEY"])
    state = pathlib.Path("slack_cursor.json")
    cursor = json.loads(state.read_text())["cursor"] if state.exists() else None
    seen = set()
    
    while True:
        page = (
            tw.innovations.changes(cursor=cursor)
            if cursor
            else tw.innovations.changes(updated_since="2026-10-01")
        )
        for inno in page.data:
            in_industry = any(i.industry_id == INDUSTRY_ID for i in inno.industries)
            if in_industry and inno.innovation_id not in seen:
                seen.add(inno.innovation_id)
                httpx.post(os.environ["SLACK_WEBHOOK_URL"], json={"text": inno.display})
        cursor = page.next_cursor or cursor
        if not page.has_more:
            break
    
    state.write_text(json.dumps({"cursor": cursor}))